<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.prime.com.tr/ui"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html">

<ui:composition template="templates/pageTemplate.xhtml">
	<f:metadata>
		<f:viewParam name="registerId"
			value="#{rcTasksEditBean.currentRegister}" />
	</f:metadata>
	<ui:define name="content">
	
		<p:growl id="growl" showDetail="true"/>
		 
		<h2>#{msgs['title.registration']}</h2>
		<h:form style="width:100%">
			<p:commandButton type="submit" value="#{msgs['action.submit']}"
				action="#{rcTasksEditBean.saveTasks}">
				<f:param name="registerId"
					value="#{rcTasksEditBean.currentRegister}" />
			</p:commandButton>
			<p:commandButton type="submit" value="#{msgs['action.draft']}"
				action="#{rcTasksEditBean.draftTasks}" update="growl,tasksList">
				<f:param name="registerId"
					value="#{rcTasksEditBean.currentRegister}" />
			</p:commandButton>
			<h:outputLink value="register.jsf" style="padding-left: 20px">
				<h:outputText value="#{msgs['action.to_register_page']}" style="font-size: 12px" />
			</h:outputLink>
			<hr />
			<p:commandButton action="#{rcTasksEditBean.addRow}"
				value="#{msgs['action.add_row']}" update="tasksList">
				<f:param name="registerId"
					value="#{rcTasksEditBean.currentRegister}" />
			</p:commandButton>
			<p:commandButton action="#{rcTasksEditBean.removeRow}"
				value="#{msgs['action.delete_row']}" update="tasksList">
				<f:param name="registerId"
					value="#{rcTasksEditBean.currentRegister}" />
			</p:commandButton>
			<br />
			<p:dataTable  var="rcTask" value="#{rcTasksEditBean.rcTasks}"
				id="tasksList" selection="#{rcTasksEditBean.selectedTask}"
				selectionMode="single" dynamic="true" liveScroll="true"
				paginator="true" rows="10"
				paginatorTemplate="{RowsPerPageDropdown} {FirstPageLink} {PreviousPageLink} {CurrentPageReport} {NextPageLink} {LastPageLink}"
				rowsPerPageTemplate="5,10,15" emptyMessage="Записей не найдено"
				style="padding-top:10px">

				<f:facet name="header">  
                        #{msgs['title.registration_of_reestr']} <strong>#{rcTasksEditBean.currentRegister}</strong>#{rcTasksEditBean.changed}
				</f:facet>

				<p:column style="width:10px" >
					<p:rowEditor/>
				</p:column>
				<!-- Edit row -->

				<p:column headerText="#{msgs['data.born_date']}" style="width:100px"
					sortBy="#{rcTask.bornDate}" filterBy="#{rcTask.bornDate}">
					<p:cellEditor>
						<f:facet name="output">
							<h:outputText value="#{rcTask.bornDate}">
								<f:convertDateTime pattern="dd.MM.yyyy" />
							</h:outputText>
						</f:facet>
						<f:facet name="input">
							<p:inputText value="#{rcTask.bornDate}" style="width:100%">
								<f:convertDateTime pattern="dd.MM.yyyy" />
							</p:inputText>
						</f:facet>
					</p:cellEditor>
				</p:column>
				<!-- Born date column -->

				<p:column headerText="#{msgs['data.surname']}" style="width:100px"
					sortBy="#{rcTask.lastName}" filterBy="#{rcTask.lastName}">
					<p:cellEditor>
						<f:facet name="output">
							<h:outputText value="#{rcTask.lastName}" />
						</f:facet>
						<f:facet name="input">
							<p:inputText value="#{rcTask.lastName}" style="width:100%" />
						</f:facet>
					</p:cellEditor>
				</p:column>
				<!-- last name column -->

				<p:column headerText="#{msgs['data.middle_name']}" style="width:100px"
					sortBy="#{rcTask.motherFIO}" filterBy="#{rcTask.middleName}">
					<p:cellEditor>
						<f:facet name="output">
							<h:outputText value="#{rcTask.middleName}" />
						</f:facet>
						<f:facet name="input">
							<p:inputText value="#{rcTask.middleName}" style="width:100%" />
						</f:facet>
					</p:cellEditor>
				</p:column>

				<p:column headerText="#{msgs['data.name']}" style="width:100px"
					sortBy="#{rcTask.name}" filterBy="#{rcTask.name}">
					<p:cellEditor>
						<f:facet name="output">
							<h:outputText value="#{rcTask.name}" />
						</f:facet>
						<f:facet name="input">
							<p:inputText value="#{rcTask.name}" style="width:100%" />
						</f:facet>
					</p:cellEditor>
				</p:column>

				<p:column headerText="#{msgs['data.birth_certificate_number']}"
					style="width:150px" sortBy="#{rcTask.birthCertificateNumber}"
					filterBy="#{rcTask.birthCertificateNumber}">
					<p:cellEditor>
						<f:facet name="output">
							<h:outputText value="#{rcTask.birthCertificateNumber}" />
						</f:facet>
						<f:facet name="input">
							<p:inputText value="#{rcTask.birthCertificateNumber}"
								style="width:100%" />
						</f:facet>
					</p:cellEditor>
				</p:column>

				<p:column headerText="#{msgs['data.maternity_hospital_number']}"
					style="width:100px" sortBy="#{rcTask.maternityHospitalNumber}"
					filterBy="#{rcTask.maternityHospitalNumber}">
					<p:cellEditor>
						<f:facet name="output">
							<h:outputText value="#{rcTask.maternityHospitalNumber}" />
						</f:facet>
						<f:facet name="input">
							<p:inputText value="#{rcTask.maternityHospitalNumber}"
								style="width:100%" />
						</f:facet>
					</p:cellEditor>
				</p:column>



			</p:dataTable>
		</h:form>
	</ui:define>
</ui:composition>
</html>
